package com.cn.action;

import java.util.Map;

import java.util.List;
import java.util.Map;

import com.cn.bean.Admin;
import com.cn.bean.Provider;
import com.cn.service.AdminService;
import com.opensymphony.xwork2.ActionContext;

public class AdminAction {
	private Admin admin;
	private Provider provider;
	public Provider getProvider() {
		return provider;
	}

	public void setProvider(Provider provider) {
		this.provider = provider;
	}
	private AdminService adminService = null;
	public Admin getAdmin() {
		return admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	public AdminService getAdminService() {
		return adminService;
	}

	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}
	//设置供应商的rank
	public void averageRank(){
		
	}

	
	public String getAllProviderByAdmin()
	{
		Map session = (Map) ActionContext.getContext().get("session");
		List list=adminService.getAllProviderByAdmin();
		System.out.println(list.size());
		session.put("AllProviderList", list);
		return "success";
	}
	
	public String acceptProvider()
	{
		Map session = (Map) ActionContext.getContext().get("session");
		Provider provider=(Provider)session.get("provider");
		int pro_id=provider.getId();
		System.out.println("要接受的供应商的id是"+pro_id);
		return adminService.acceptProvider(pro_id);
		
	}
	public String rejectProvider()
	{
		Map session = (Map) ActionContext.getContext().get("session");
		Provider provider=(Provider)session.get("provider");
		int pro_id=provider.getId();
		System.out.println("要拒绝的供应商的id是"+pro_id);
		return adminService.rejectProvider(pro_id);
		
	}

}
